#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct btree
{
    struct btree *lchild;
    void *data;
    struct btree *rchild;
}btree_t;

typedef unsigned long int	uintptr_t;

//创建一个二叉树
btree_t *create_btree();
//先序遍历
void preorder_Traversal(btree_t *root);

char str[]={"AB*E**C*F**"};
 static int i=0;
//创建一个二叉树
btree_t *create_btree()
{
    if(str[i]=='*')
    {
        i++;
        return NULL;
    }
    btree_t *root=(btree_t *)malloc(sizeof(btree_t));
    if(root==NULL)
    {
        return NULL;
    }
    root->data=(void *)(uintptr_t)str[i];
    i++;
    root->lchild=create_btree();
    root->rchild=create_btree();
    return root;
}

//先序遍历
void preorder_Traversal(btree_t *root)
{
    if(root==NULL)
    {
        return ;
    }
    printf("%c\t",(char)(uintptr_t)root->data);
    preorder_Traversal(root->lchild);
    preorder_Traversal(root->rchild);
}
int main(int argc, char const *argv[])
{
    btree_t *root=create_btree();
    printf("先序遍历\n");
    preorder_Traversal(root);
    printf("\n");
    return 0;
}
